﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleAppServer.Core
{
    /// <summary>
    /// IAppServer
    /// </summary>
    public interface IAppServer
    {
        /// <summary>
        /// 接收事件
        /// </summary>
        event EventHandler<ReceivedArgs> Received;

        /// <summary>
        /// Session注册事件
        /// </summary>
        event EventHandler<AppSessionArgs> RegistSession;

        /// <summary>
        /// Session注销事件
        /// </summary>
        event EventHandler<AppSessionArgs> UnRegistSession;

        /// <summary>
        /// 是否运行状态
        /// </summary>
        bool IsRunning { get; }

        /// <summary>
        /// 安装服务配置
        /// </summary>
        /// <param name="config">服务配置</param>
        /// <returns>安装成功或失败</returns>
        void Setup(IServerConfig config);

        /// <summary>
        /// 开启服务
        /// </summary>
        /// <returns>开启成功或失败</returns>
        bool Start();

        /// <summary>
        /// 结束服务
        /// </summary>
        void End();

        /// <summary>
        /// 获取所有Session
        /// </summary>
        /// <returns>IList</returns>
        IList<IAppSession> GetAllSession();

        /// <summary>
        /// 创建Session
        /// </summary>
        /// <param name="token">User Token</param>
        /// <returns>AppSession</returns>
        IAppSession CreateSession(object token=null);
    }
}